package com.example.pjsipgo;

import android.app.Application;
import android.content.Context;
import android.os.Build;

import com.tencent.bugly.Bugly;

import java.lang.reflect.Field;
import java.lang.reflect.Method;


/**
 * File description.
 *
 * @author sana
 * @date 2021/12/15
 */
public class MyApplication extends Application {
//    private PjsipUtils mPjSip;
    private static Context context;
    private static MyApplication application;
    /**
     * 开发模式
     */
    public static boolean IS_DEBUG = true;

    public static String TY_KEY = "41f1f3e2359142a0bdb68a6170a0cc43";
    private static final String BugLy_APP_ID = "d57c8afc74";

    private boolean isBusy ;
    public static Context getContext() {
        return context;
    }


    @Override
    public void onCreate() {
        super.onCreate();
        application = this;
        context = getApplicationContext();
        Bugly.init( getApplicationContext(), BugLy_APP_ID, false );
        disableAPIDialog();

    }

    /**
     * 反射 禁止弹窗
     */
    private void disableAPIDialog() {
        if (Build.VERSION.SDK_INT < 28) {
            return;
        }
        try {
            Class clazz = Class.forName( "android.app.ActivityThread" );
            Method currentActivityThread = clazz.getDeclaredMethod( "currentActivityThread" );
            currentActivityThread.setAccessible( true );
            Object activityThread = currentActivityThread.invoke( null );
            Field mHiddenApiWarningShown = clazz.getDeclaredField( "mHiddenApiWarningShown" );
            mHiddenApiWarningShown.setAccessible( true );
            mHiddenApiWarningShown.setBoolean( activityThread, true );
        } catch (Exception e) {
            e.printStackTrace();
        }
    }



}
